use serde::{Deserialize, Serialize};

use super::{Input, NodeTrait, Output};

#[derive(Clone, Serialize, Deserialize)]
pub struct IncludeModuleRefNode {
    pub ref_node_name:String,
    pub file: String,
    inputs: Vec<super::Input>,
    outputs: Vec<super::Output>,
    description: String,
}

impl IncludeModuleRefNode {
    pub fn new(file:String, ref_node_name:String) -> Self {
        Self {
            description: format!("外部模块引用节点，引用自文件: {}", file),
            ref_node_name,
            file,
            inputs: vec![
                super::Input {
                    name: "Ref".to_string(),
                    description: Some("引用模块".to_string()),
                    value: crate::graph::value::Value::Node,
                }
            ],
            outputs: vec![],
        }
    }
}

impl NodeTrait for IncludeModuleRefNode {
    fn name(&self) ->  &str {
        ""
    }

    fn ty(&self) ->  &str {
        "__INCLUDE_MODULE_REF_NODE__"
    }

    fn description(&self) -> Option<&str> {
        Some(&self.description)
    }

    fn inputs(&self) ->  &[Input] {
        &self.inputs
    }

    fn outputs(&self) ->  &[Output] {
        &self.outputs
    }

    fn has_children(&self) -> bool {
        false
    }

    fn inputs_mut(&mut self) ->  &mut Vec<Input> {
        &mut self.inputs
    }

    fn outputs_mut(&mut self) ->  &mut Vec<Output> {
        &mut self.outputs
    }
}
